public class Solution526 {
    int[] used=new int[20];
    int count=0;

    public void search(int k,int n){
        if (k>n){
            count++;
            return;
        }
        for (int i=1;i<=n;i++){
            if (used[i]==0&&(i%k==0||k%i==0)){
                used[i]=1;
                search(k+1,n);
                used[i]=0;
            }
        }
    }

    public int countArrangement(int n) {
        search(1,n);
        return count;
    }

    public static void main(String[] args) {
        System.out.println(new Solution526().countArrangement(2));
    }
}
